package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
)

var demoCmd = &cobra.Command{
	Use:   "demo",
	Short: "test demo",
	Long:  "代码调试",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		// 重写父级
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		// 初始化
		//core.Init()
	},
	Run: func(cmd *cobra.Command, args []string) {
		arr := []int{1, 2, 3, 4, 5, 6}
		log.Println(arr[5:6])
		//name := "WechatIMG505.png"
		//n := strings.LastIndex(name, ".")
		//if n > -1 {
		//	log.Println(name[:n], name[n+1:])
		//}
	},
	PostRun: func(cmd *cobra.Command, args []string) {
		//core.Shutdown()
	},
}

func formatExcelAxis(r, index int) string {
	if index < 26 {
		return fmt.Sprintf("%s%d", []byte{byte(index%26 + 65)}, r)
	}
	b := []byte{byte(index/26 - 1 + 65), byte(index%26 + 65)}

	return fmt.Sprintf("%s%d", b, r)
}
